 //Tables: 
 
 
use ABD_wave1, clear 
 
est clear 
foreach var of varlist defense_dv education_dv  infa_dv{
reg `var'  Thr_treat, robust
est sto e_`var' 
}

lab var Thr_treat "Threat Treatment"
//lab var debt_treat "Debt Treat."

#delimit ;   
coefplot (e_defense_dv, label(Defense Spending)  mcolor(blue) levels(95 90) ciopts(lcolor(blue blue))) 
		 (e_infa_dv, label(Infastructure Spending) pstyle(p3) levels(95 90))
		 (e_education_dv, label(Education Spending)pstyle(p2) levels(95 90)),
		 drop(_cons) xline(0) scheme(s1mono)   ; 
 #delimit cr
 
   
// size of effect: 
reg defense_dv debt_treat Thr_treat, robust
qui sum defense_dv, det 
di _b[Thr_treat]/`r(sd)' 
 
tab Thr_treat if e(sample)
 
reg infa_dv debt_treat Thr_treat, robust
qui  sum infa_dv, det 
 di _b[Thr_treat]/`r(sd)' 
 
reg education_dv debt_treat Thr_treat, robust level(90)
qui  sum education_dv, det 
di _b[Thr_treat]/`r(sd)' 
 


// Trade-off Models:

twoway (histogram defvstax2 if Thr_treat==1, percent discrete color(blue%50)) ///
       (histogram defvstax2 if Thr_treat==0,  percent discrete color(red%50)), ///
	   name(histtax, replace) legend(order(1 "Threat" 2 "Control" )) scheme(s1mono) xtitle("" )xlabel(0(1)2, labsize(vsmall) angle(forty_five) valuelabel)

twoway (histogram defvsdom2 if Thr_treat==1, percent discrete color(blue%50)) ///
       (histogram defvsdom2 if Thr_treat==0,  percent discrete color(red%50)), ///
	   name(histdom, replace) legend(order(1 "Threat" 2 "Control" )) scheme(s1mono) xtitle("" )xlabel(0(1)2, labsize(vsmall) angle(forty_five) valuelabel)

graph combine histtax histdom, scheme(s1mono)	ycommon  






est clear
mlogit defvsdom2 Thr_treat, base(2) r
est sto _m1 
margins, dydx(Thr_treat) post
ereturn list
#delimit ; 
coefplot, rename(1._predict = "Pr(Dom. Cuts)"
				2._predict = "Pr(Mil. Cuts)"
				3._predict = "Pr(Neither)") 
				xline(0) levels(95) scheme(s1mono)
				msymbol(circle) mcolor(red) mcolor(blue) ciopts(lcolor(blue))
				name(spending, replace) title("Dom.-Mil. Spending Tradeoff") ;
#delimit cr



mlogit defvstax2  Thr_treat, base(2) r
est sto _m2

margins, dydx(Thr_treat) post
ereturn list
#delimit ; 
coefplot, rename(1._predict = "Pr(Taxes)"
				2._predict = "Pr(Mil. Cuts)"
				3._predict = "Pr(Neither)") 
				xline(0) levels(95) scheme(s1mono)
				msymbol(circle) mcolor(red) mcolor(red) ciopts(lcolor(red))
				name(tax, replace) title("Spending-Tax Tradeoff") ;
#delimit cr

graph combine tax spending,  xcommon scheme(s1mono)





// Pre-Post Invasion Models: 

use ABD_2waves, clear



est clear 
foreach var of varlist C_defense_dv C_education_dv  C_infa_dv{
reg `var' wave2_bi , robust cl(resp_id)
//xtreg `var' wave2_bi , robust cl(resp_id)

est sto e_`var' 
}



#delimit ;   
coefplot (e_C_defense_dv, label(Defense Spending) pstyle(p4) mcolor(blue) ciopts(lcolor(blue blue))) 
		 (e_C_infa_dv, label(Infastructure Spending) pstyle(p3))
		 (e_C_education_dv, label(Education Spending)pstyle(p2) ),
		 drop(_cons) xline(0) scheme(s1mono) levels(95 90) 
		ciopts(lwidth(medium thick) lpattern(line line)); 
 #delimit cr



est clear 
foreach var of varlist C_defense_dv C_education_dv  C_infa_dv{
reg `var' wave2_bi , robust cl(resp_id)
est sto e_`var' 

oprobit `var' wave2_bi , robust cl(resp_id)

est sto e_O`var' 
} 
 

 
 est clear 
mlogit defdom wave2_bi , base(2) cl(resp_id)
est sto mlogit1

margins, dydx(wave2_bi) post
ereturn list
#delimit ; 
coefplot, rename(1._predict = "Pr(Dom. Cuts)"
				2._predict = "Pr(Mil. Cuts)"
				3._predict = "Pr(Neither)") 
				xline(0) levels(95 90)  
				msymbol(circle) mcolor(red) mcolor(blue) 
				ciopts( lcolor(blue red) lwidth(medium thick) lpattern(line line))
				name(spending, replace) title("Dom.-Mil. Spending Tradeoff") scheme(s1mono)  ;
#delimit cr


mlogit deftax wave2_bi , base(2) cl(resp_id)
est sto mlogit2

margins, dydx(wave2_bi) post
ereturn list
#delimit ; 
coefplot, rename(1._predict = "Pr(Taxes)"
				2._predict = "Pr(Mil. Cuts)"
				3._predict = "Pr(Neither)") 
				xline(0) levels(95 90) 
				msymbol(circle) mcolor(red) mcolor(blue) 
				ciopts(lcolor(blue red) lwidth(medium thick) lpattern(line line))
				name(tax, replace) title("Spending-Tax Tradeoff") scheme(s1mono) noeqlabels ;
#delimit cr

graph combine tax spending,  xcommon scheme(s1mono)
 
 

 
////////// Appendix ///////////




 
use ABD_wave1, clear 
 
 
//////////////////////////////////////////////////
// Balance of  experiment 
////////////////////////////////////////////////// 
 

use ABD_wave1, clear 

tabstat age female LR, by(Thr_treat) stats(mean sd)
tab mac_region Thr_treat, col
 
 
//////////////////////////////////////////////////
// Distribution of variables 
////////////////////////////////////////////////// 
 
foreach var of varlist defense_dv education_dv  infa_dv{
reg `var' debt_treat Thr_treat, robust
 
hist `var' if e(sample), dis percent scheme(s1mono)  xlabel(0(1)4) name(g_`var', replace)
}
graph combine g_defense_dv g_education_dv  g_infa_dv, scheme(s1mono) col(3)



 
 
 



 

/////////////////////////
// Interaction w/ Unreported Treatment 
/////////////////////////

use ABD_wave1, clear 

  gen Thr_treatd0 = Thr_treat
  replace Thr_treatd0 = 0 if debt_treat==0
  
  gen Thr_treatd1 = Thr_treat
  replace Thr_treatd1 = 0 if debt_treat==1
  
  label var Thr_treatd1 "Threat when Debt = 0"
  label var Thr_treatd0 "Threat when Debt = 1"
  
  
  reg defense_dv  debt_treat Thr_treatd1 Thr_treatd0, robust
	est sto e_defense_dv

#delimit ;   
coefplot (e_defense_dv, drop(debt_treat _cons) label(Defense Spending) pstyle(p4) mcolor(blue) ciopts(lcolor(blue))) ,
		 drop(_cons) xline(0) scheme(s1mono)  ; 
#delimit cr
  
  
  
 mlogit defvsdom2 debt_treat Thr_treatd1 Thr_treatd0, base(2)
 margins, dydx(Thr_treatd1) post
 est sto margins0

  mlogit defvsdom2 debt_treat Thr_treatd1 Thr_treatd0, base(2)
 margins, dydx(Thr_treatd0) post
 est sto margins1
 
 
#delimit ; 
coefplot (margins1, label("Debt Treat = 0") color(red) msymbol(D)) (margins0, label("Debt Treat = 1") color(blue)), 
rename(1._predict = "Pr(Dom. Cuts)"
				2._predict = "Pr(Mil. Cuts)"
				3._predict = "Pr(Neither)")
				xline(0) levels(95) scheme(s1mono)
				msymbol(circle) 
				name(spending, replace) title("Dom.-Mil. Spending Tradeoff") ;
#delimit cr
  



mlogit defvstax2  debt_treat Thr_treatd1 Thr_treatd0, base(2)
est sto _m2

#delimit ; 
coefplot (margins1, label("Debt Treat = 0") color(red) msymbol(D)) (margins0, label("Debt Treat = 1") color(blue)), 
rename(1._predict = "Pr(Dom. Cuts)"
				2._predict = "Pr(Mil. Cuts)"
				3._predict = "Pr(Neither)")
				xline(0) levels(95) scheme(s1mono)
				msymbol(circle) 
				name(tax, replace) title("Spending-Tax Tradeoff") ;
#delimit cr  




//////////////////////////////////////////////////
// compare demographics among attrition groups: 
//////////////////////////////////////////////////
use attrition_review, clear

tab  attrition if WAVE2==0

tabstat female if WAVE2==0, by(attrition)
tabstat age if WAVE2==0, by(attrition)
tabstat leftright if WAVE2==0, by(attrition)


tab mac_region attrition if WAVE2==0, col
   
  
   
//////////////////////////////////////////////////
// Manipulation Checks 
//////////////////////////////////////////////////  
use ABD_wave1, clear 

ttest warprob , by(Thr_)
ttest NATOc , by(Thr_)


/////////////////////////////////////////////////////
 /// IIA test 
/////////////////////////////////////////////////////
  
use ABD_wave1, clear 

 set seed 22005
est clear 
mlogit deftax Thr_treat , base(2)  
mlogtest, haus


est clear 
mlogit defdom Thr_treat , base(2) 
mlogtest, haus  
  
  
use ABD_2waves, clear
 
 set seed 22005
est clear 
mlogit deftax wave2_bi , base(2)  
mlogtest, haus


est clear 
mlogit defdom wave2_bi , base(2) 
mlogtest, haus




 
//////////////////////////////////////////////////
// Effect on Military Spending Subsets 
//////////////////////////////////////////////////  
 
 
est clear 
foreach var of varlist personnel equipment operating milinfastructure{
qui reg `var'  Thr_treat, robust
qui sum `var' 
di _b[Thr_treat]/`r(sd)'
est sto e_`var' 
}

lab var Thr_treat "Threat Treatment"
//lab var debt_treat "Debt Treat."

#delimit ;   
coefplot (e_personnel, label(Personnel)  mcolor(blue) levels(95 90) ciopts(lcolor(blue blue))) 
		 (e_equipment, label(Equipment) mcolor(green) levels(95 90) ciopts(lcolor(green green)))
		 (e_operating, label(Operating and Maintenance) mcolor(red) levels(95 90)  ciopts(lcolor(red red)))
		 (e_milinfastructure, label(Military Infastructure) mcolor(black) levels(95 90)  ciopts(lcolor(black black))),
		 drop(_cons) xline(0) scheme(s1mono)   ; 
 #delimit cr
 
